<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <title>杨澎锴的学习实践26-vuejs事件</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <button v-on:click="say">Vue.js</button>
      <p v-on:click="say">Vue.js</p>
    </div>

    <script>
      var app = new Vue({
        el: "#app",
        methods: {
          // 使用函数来实现事件
          say: function () {
            alert("welcome");
          },
        },
      });
    </script>
  </body>
</html>
